﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using FreeProperty.Views.Shared;
using FreeProperty.Data;
using System.Data.SqlTypes;

namespace FreeProperty.Views.User
{
    public partial class CreateUser : SiteBasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                SetUI();
            }
            else
            {
                lblError.Text = "";
                switch (hdnMode.Value.ToUpper())
                {
                    case "SAVEUSER":
                        SaveUser();
                        break;
                    
                }
            }
        }

        private void SaveUser()
        {
            UserInfo oUserInfo = new UserInfo();
            oUserInfo.EmailID = tbEmailId.Value.Trim();
            oUserInfo.Password = tbPassword.Value.Trim();
            oUserInfo.Name = tbName.Value.Trim();
            oUserInfo.ContactNo = tbPhoneNo.Value.Trim();
            SqlInt32 iError =  oUserInfo.Save();
            if (iError > 0)
            {
                lblError.Text = oUserInfo.GetErrorMessage(iError);
            }
            else
            {
                lblError.Text = "User created successfully.";
            }
        }

        private void SetUI()
        {
            
        }
    }
}
        